<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>
		修改密码
	</title>

    <meta name="viewport" content="width=device-width"/>
    <meta name="viewport" content="initial-scale=1.0,user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name = "format-detection" content = "telephone=no">
    
    <link type="text/css" href="css/css.css" rel="stylesheet" />


     <script type="text/javascript">  
    //iOS Web APP中点击链接跳转到Safari 浏览器新标签页的问题 devework.com  
    //stanislav.it/how-to-prevent-ios-standalone-mode-web-apps-from-opening-links-in-safari  
    if(("standalone" in window.navigator) && window.navigator.standalone){  
        var noddy, remotes = false;  
        document.addEventListener('click', function(event) {  
            noddy = event.target;
            while(noddy.nodeName !== "A" && noddy.nodeName !== "HTML") {  
                noddy = noddy.parentNode;  
            }  
            if('href' in noddy && noddy.href.indexOf('http') !== -1 && (noddy.href.indexOf(document.location.host) !== -1 || remotes))  
            {  
                event.preventDefault();  
                document.location.href = noddy.href;  
            }  
        },false);  
    }  
  </script> 

</head>
<body>
<div class="login">
    <div class="header">
    <table width="100%" border="0" cellspacing="0" class="header_nav">
        <tr>
            <td width="10%" class="nav_left1"><a  href='javascript:window.history.go(-1)'><</a></td>
            <td width="70%" class="nav_title">修改密码</td>
            <td width="20%" class="nav_r"></td>
        </tr>
    </table>
    </div>
        <div class="logo"></div>
        <div class="main">

            <CENTER>
                <div id="dd">
                    <form enctype="multipart/form-data" id="upform">
                        <a href="javascript:void(0);" class="file" cellspacing="0">
                            +
                            <input type="file" class="imgfile" name="imgurl" id="inputs" onchange="a()">
                        </a>
                    </form>
                </div>
            </CENTER>


        	<table width="100%" border="0" cellspacing="0" class="mainl">
            	<tr>
                    <td class="text"><input type="text/css" id="nickname" placeholder="请输入您的昵称" class="text1"/></td>
                </tr>
            </table>
            <div class="linee"></div>
			<table width="100%" border="0" cellspacing="0" class="mainl">
                <tr>
                    <td class="text"><input type="text/css" id="email" placeholder="请输入您的e-mail" class="text1"/></td>
                </tr>
            </table>
            <div class="linee"></div>
            <table width="100%" border="0" cellspacing="0" class="mainl">
                <tr>
                    <td class="text"><input type="text/css" id="telephone"  placeholder="请输入您的电话" class="text1"/></td>
                </tr>
            </table>
            <div class="linee"></div>
            <table width="100%" border="0" cellspacing="0" class="mainl">
                <tr>
                    <td class="text"><input type="text/css" id="password" placeholder="请输入您的新密码" class="text1"/></td>
                </tr>
            </table>
            <div class="linee"></div>
            

        </div>
        <div class="button"><input type="submit" onclick="javascript:changepassword()" value="确认修改" class="text2" /></div>
    </div>
	<script src="js/jquery.min.js"></script>
	<script src="js/app.js"></script>
</body>
	<script type="text/javascript">
	var imgurl;
    var rootdir="http://libkindle.com:8080/WebSell/";
    function a(){
        var formData=new FormData($('form')[0]);
        //formData.append('file',$(':file')[0].files[0]);
        $.ajax({
            url: rootdir+"PictureServlet",
            type: 'POST',
            data: formData,
            contentType: false,
            processData:false,
            dataType: 'json',
            success: function(data,status,xhr) { 
                if(data.code==0){
                    imgurl=data.iconurl;
                    $("#dd").empty();
                    $("#dd").append("<img src='"+rootdir+imgurl+"''>");
                    console.log(rootdir+imgurl);
                }
                else{
                    alert(data.msg);
                }
            },
            error: function(data,XMLHttpRequest,textStatus,errorThrown){
                alert("上传意外出错");
                console.log(data);
                console.log(XMLHttpRequest.status);
                console.log(XMLHttpRequest.readyState);
                console.log(textStatus);
            },
        });
    };
	
	
	
	
	
	
	
	function changepassword(){
      	$.ajax({
            url: rootdir+"LoginServlet",
            type: 'GET',
            dataType: 'json',
            data: {
				action:"change",
				icon:rootdir+imgurl,
				nickname:$("#nickname").val(),
				email:$("#email").val(),
				telephone:$("#telephone").val(),
				password:$("#password").val()
			},
            success: function(data,status,xhr) { 
				if(data.code==0){
				alert(data.msg);
				location.href = "login.html";
				}
 				else{
           			alert(data.msg);
           		}           		
            },
            error: function() {
            	alert("密码错误");
            	window.location.href = "#";
            },
        });
    };
	
	
	
	
	
	
	
	

   
    function tianjia(){
        $.ajax({
            url: rootdir+"LoginServlet",
            type: 'GET',
            dataType: 'json',
            data: {
                action:"change",
                nickname:$("#nickname").val(),
                password:$("password").val(),
                telephone:$("telephone").val(),
                email:$("#email").val(),
                icon:rootdir+imgurl
            },
            success: function(data,status,xhr) { 
                if(data.code==0){
                    alert(data.msg);
                    location.href = "index.html";
                }
                else{
                    alert(data.msg);
                }
            },
            error: function() {
                alert("发送意外出错");
                console.log(data);
                console.log(XMLHttpRequest.status);
                console.log(XMLHttpRequest.readyState);
                console.log(textStatus);
            },
        });
    };


	
	
	
	
	
	
	
	
	
	
	
	
	
	
</script>


</html>